<% layout('/layouts/default.html', {title: '任务部署信息表(主)管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<#form:form id="searchForm" model="${dcSupTaskInfo}" action="${ctx}/taskdeploy/dcSupTaskInfoSecretary/findListData?taskStatus=1&normalFlag=2" method="post" class="form-inline"
			data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
			<#form:hidden path="messageNumber"/>
			<#form:hidden path="taskYear"/>
			<#form:hidden path="taskTitle"/>
			<#form:hidden path="taskTypeCode"/>
		</#form:form>
	</div>
	<div class="box-body">
		<%
		var officeCode =@com.jeesite.modules.utils.OfficeUtil.getCurrentOffice().getOfficeCode();
		var userCode =@UserUtils.getUser().getUserCode();
		 %>
		<table id="dataGrid"></table>
		<div id="dataGridPage"></div>
	</div>
</div>
</div>
<% } %>
<script>
	//重置
	function cz(){
		searchForm.reset();
		$('#dataGrid').dataGrid('reloadGrid');
	}

	//打开新的标签
	function addTask() {
		js.addTabPage(null, "新增督办事项","${ctx}/taskdeploy/dcSupTaskInfo/form?normalFlag="+1, true);
	}
	function addTaskMulti() {
		js.addTabPage(null, "新增督办事项","${ctx}/taskdeploy/dcSupTaskInfo/multiForm?normalFlag="+2, true);
	}

	// 初始化DataGrid对象
	$('#dataGrid').dataGrid({
		searchForm: $("#searchForm"),
		sortableColumn: false, // 列表不允许排序
		columnModel: [
			{header:'${text("主键")}', name:'id', index:'a.id', width:150, align:"left", hidden:true},
			{header:'${text("督办字号")}', name:'messageNumber', index:'a.message_number', width:100, align:"left"
				, formatter: function(val, obj, row, act){
					if (val) {
						return val;
					} else {
						return "暂无字号";
					}
				}
			},
			{header:'${text("任务标题")}', name:'taskTitle', index:'a.task_title', width:150, align:"left"},
			{header:'${text("任务类型")}', name:'taskTypeName', index:'a.task_type_name', width:150, align:"left"},
			{header:'${text("任务内容")}', name:'taskContent', index:'a.task_content', width:150, align:"left"
				, formatter: function(val, obj, row, act){
					return '<a href="${ctx}/taskdeploy/dcSupTaskInfo/detailForm?id='+row.id+'" class="btnList" data-title="${text("督办任务信息")}">'+(val||'暂无内容')+'</a>';
				}
			},
			{header:'${text("牵头领导")}', name:'taskLeaderName', index:'a.task_leader_name', width:150, align:"left"},
			{header:'${text("牵头责任单位")}', name:'taskLeaderOrgName', index:'a.task_leader_org_name', width:150, align:"left"},
			{header:'${text("任务状态")}', name:'taskStatus', index:'a.task_status', width:150, align:"center"
				,formatter: function(val, obj, row, act){
					return js.getDictLabel(${@DictUtils.getDictListJson('dc_task_status')}, val, '${text("未知")}', true);
				}},
			{header:'${text("操作")}', name:'actions', width:100, align:"center",hidden: true,formatter: function(val, obj, row, act){
					var actions = [];
						if('${@UserUtils.getUser().getUserCode()}' == 'system'||row.createBy == '${@UserUtils.getUser().getUserCode()}'){
							actions.push('<a href="#" class="btn btn-primary btn-xs " onclick=editTask("'+row.id+'") title="${text("编辑督办事项")}">编辑</a>&nbsp;&emsp;');
						}
					return actions.join('');
				}}
		],
		// 加载成功后执行事件
		ajaxSuccess: function(data){

		}
	});

	// 编辑任务
	function editTask(id) {
		js.addTabPage(null, "编辑督办任务","${ctx}/taskdeploy/dcSupTaskInfo/form?id="+id , true);
	}

	// 导入
	$('#btnImport').click(function(){
		js.layer.open({
			type: 1,
			area: ['400px'],
			title: '${text("导入督办数据")}',
			resize: false,
			scrollbar: true,
			shadeClose: false,
			content: js.template('importTpl'),
			success: function(layero, index){
				layero.find('input[type="checkbox"]').iCheck();
			},
			btn: ['<i class="fa fa-check"></i> ${text("导入")}',
				'<i class="fa fa-remove"></i> ${text("关闭")}'],
			btn1: function(index, layero){
				var form = {
					inputForm: layero.find('#inputForm'),
					file: layero.find('#file').val()
				};
				if (form.file == '' || (!js.endWith(form.file, '.xls') && !js.endWith(form.file, '.xlsx'))){
					js.showMessage("${text('文件不正确，请选择后缀为“xls”或“xlsx”的文件。')}", null, 'warning');
					return false;
				}
				js.ajaxSubmitForm(form.inputForm, function(data){
					js.showMessage(data.message);
					if(data.result == Global.TRUE){
						js.layer.closeAll();
					}
					page();
				}, "json");
				return true;
			}
		});
	});
	function returnHtml (){
		var messageNumber =encodeURIComponent($("#messageNumber").val());
		var taskTitle =encodeURIComponent($("#taskTitle").val());
		$("#ret").attr("href","${ctx}/taskdeploy/dcSupTaskInfoSecretary/titleForm?messageNumber="+messageNumber+"&taskYear="+$("#taskYear").val()+"&taskTitle="+taskTitle+"&taskTypeCode="+$("#taskTypeCode").val());
	}
</script>